<template>
	<view class="content">
		<view class="nav-item">
			<view class="nav-left">
				<text class="iconfont icon-logo"></text>
				<text> 高佳</text>
			</view>
			<view class="nav-right" @click="showDrawer">
				<text class="iconfont icon-menu"></text>
			</view>
		</view>
		
		<uni-drawer ref="rightDrawer" :width=120 mode='right'>
			<view class="categoryList" v-for="item in categoryList">
				<button>{{item.name}}</button>
			</view>
		</uni-drawer>
		<swiper circular indicator-dots>
			<swiper-item v-for="item in carouselList" key="item.adId">
				<image :src="item.filePath"></image>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
	import { findAd, findAllMenu } from '../../api/home'
	
	export default {
		data() {
			return {
				title: '高佳',
				carouselList:[],
				categoryList:[],
			}
		},
		onLoad() {
			this.getHomeData()
		},
		methods: {
			getHomeData() {
				let self = this;
				uni.showLoading({
				    title: '加载中'
				});
				
				findAd("homeCarousel").then(data => {
					  self.carouselList = data.list;
				});
				
				findAllMenu().then(data => {
					self.categoryList = data.list;
					console.log('12123 ' + data.list)
					uni.hideLoading()
				})	
				
			},
			showDrawer() {
				this.$refs.rightDrawer.open();
			},
			closeDrawer(){
				this.$refs.rightDrawer.close();
			}
		}
	}
</script>

<style lang="less">
	.content {
		.nav-item {
			display: flex;
			justify-content: space-between;
			margin: 40rpx;
		}
		swiper {
			width: 750rpx;
			height: 470rpx;
			image {
				width: 100%;
				height: 100%;
			}
		}
	}
</style>
